<?php

namespace app\admin\model;

use think\Model;

class ApprovalProcess extends Common
{

    /**
     * 待审核
     * @var int
     */
    public static $AUDIT_WAITING = 1;
    /**
     * 审核通过
     * @var int
     */
    public static $AUDIT_PASS = 2;
    /**
     * 审核拒绝
     * @var int
     */
    public static $AUDIT_REJECT = 3;
    /**
     * 审核排队等待中
     * @var int
     */
    public static $AUDIT_QUEUE_WAIT = 4;

    public function user()
    {
        return $this->belongsTo('User', 'uid', 'id');
    }

    public function appForm()
    {
        return $this->belongsTo('AppForm', 'id', 'app_form_id');
    }

    protected function scopeUnReview($query)
    {
        $query->where('status', 1);
    }


    public function getAppTimeAttr(){
        return date('Y-m-d H:i:s',$this->getData('app_time'));
    }

    public function getStatusTxtAttr($value, $data)
    {

        $statuses = [
            1 => '待审核',
            2 => '通过',
            3 => '拒绝',
            4 => '待审核',
        ];
        return $statuses[$data['status']];
    }


}
